package redis.inaction.clients;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import redis.inaction.clients.ops.JedisOps;
import redis.inaction.clients.ops.LettuceOps;

@Slf4j
@SpringBootApplication
public class DemoApplication implements ApplicationRunner {

	@Autowired
	private JedisOps jedisOps;

	@Autowired
	private LettuceOps lettuceOps;

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}


	@Override
	public void run(ApplicationArguments args) throws Exception {
		if( jedisOps.isJedisInitialized() ){
			log.info("Jedis has been initialized, let it do something...");
			jedisOps.doSomething();
		} else {
			log.info("No jedis initialized.");
		}

		if( lettuceOps.isLettuceInitialized() ){
			log.info("Lettuce has been initialized, let it do something...");
			lettuceOps.doSomething();
		} else {
			log.info("No Lettuce initialized.");
		}
	}
}

